-
Notifications
You must be signed in to change notification settings - Fork 24.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Two queries for keyword script field #59527
Two queries for keyword script field #59527
Conversation
This adds the `exits` and `terms` query for the `keyword` style of scripted field.
Pinging @elastic/es-search (:Search/Search) |
I picked these two queries to do next because they are fairly simple and prove that we can add more queries. I haven't tried to share any code between the queries yet because I figure it'll be more obvious what we can and should share once we have a few more queries. |
.../src/main/java/org/elasticsearch/xpack/runtimefields/query/StringScriptFieldExistsQuery.java
Outdated
Show resolved
Hide resolved
|
||
@Override | ||
public String bareToString() { | ||
return "*"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get it, but I find this cryptic. For instance looking at what DocValuesFieldExistsQuery does , that is clearer to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can keep the original toString
impls.
} | ||
StringScriptFieldTermsQuery other = (StringScriptFieldTermsQuery) obj; | ||
return other.terms.equals(other.terms); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we have unit tests for equals/hashcode , toString and visit for all the queries that we introduce?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
possibly also matches but that is already tested
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. equals
and hashcode
are cache keys. toString
probably isn't all that important but we may as well do it while we're there. Visit is important for highlighting, or, at least, it will be. So we should do it too.
|
||
@Override | ||
public int hashCode() { | ||
// TODO should leafFactory be here? Something about the script probably should be! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point. what do we need to address this TODO? Would we need to pass in the Script itself?
if (fieldName().contentEquals(field)) { | ||
return "*"; | ||
} | ||
return fieldName() + ":*"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we said we would adapt toString for the exists query to be something more aligned with DocValuesFieldExistsQuery in lucene
} | ||
}); | ||
assertThat(allTerms, equalTo(query.terms().stream().map(t -> new Term(query.fieldName(), t)).collect(toCollection(TreeSet::new)))); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for adding all these tests!!!
This adds the
exists
andterms
query for thekeyword
style ofscripted field.
relates to #59332